﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using FBGraph.ClientGenerator.CodeGen;

namespace FBGraph.ClientGenerator.Tests.CodeGen
{
    [TestClass]
    public class XmlDocCommentListTests
    {
        [TestMethod]
        public void SuggestAddsFirstSummaryComment()
        {
            var list = new XmlDocCommentList();
            var item = new XmlDocComment("<summary>This is a description</summary>");
            list.Suggest(item);

            Assert.IsTrue(list.Contains(item));
        }

        [TestMethod]
        public void SuggestIgnoresSubsequentSummarySuggestions()
        {
            var list = new XmlDocCommentList();
            var item1 = new XmlDocComment("<summary>This is a description</summary>");
            var item2 = new XmlDocComment("<summary>This is a redundant description</summary>");
            list.Suggest(item1);
            list.Suggest(item2);

            Assert.IsTrue(list.Contains(item1));
            Assert.IsFalse(list.Contains(item2));
        }

        [TestMethod]
        public void SuggestAddsSummaryAndRemarks()
        {
            var list = new XmlDocCommentList();
            var item1 = new XmlDocComment("<summary>This is a description</summary>");
            var item2 = new XmlDocComment("<remarks>This has more detailed information</remarks>");
            list.Suggest(item1);
            list.Suggest(item2);

            Assert.IsTrue(list.Contains(item1));
            Assert.IsTrue(list.Contains(item2));
        }

        [TestMethod]
        public void OutputOneComment()
        {
            var list = new XmlDocCommentList("<summary>This is a description</summary>");

            var expected = @"/// <summary>This is a description</summary>
";
            var actual = list.ToString();

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void OutputMultipleComments()
        {
            var list = new XmlDocCommentList("<summary>This is a description</summary>", "<remarks>This has more detailed information</remarks>");

            var expected = @"/// <summary>This is a description</summary>
/// <remarks>This has more detailed information</remarks>
";
            var actual = list.ToString();

            Assert.AreEqual(expected, actual);
        }
    }
}